package com.seecen.cywbackend.controller;

import com.seecen.cywbackend.pojo.vo.GroupVO;
import com.seecen.cywbackend.service.GroupService;
import com.seecen.cywbackend.utils.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/group")
public class GroupController {
    @Resource
    private GroupService groupService;

    @GetMapping("/getInfo/{groupId}")
    public Result getGroupDetail(
            @PathVariable Integer groupId,
            @RequestHeader String uid) {
        Long userId = Long.parseLong(uid);
        return groupService.getGroupDetail(groupId, userId);
    }

    // 搜索圈子（新增接口）
    @GetMapping("/search")
    public Result searchGroups(
            @RequestParam(required = false) String keyword,
            @RequestHeader String uid) {
        Long userId = Long.parseLong(uid);
        return groupService.searchGroups(keyword, userId);
    }
}
